package com.pzb.web.controller.market;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.pzb.common.annotation.Log;
import com.pzb.common.core.controller.BaseController;
import com.pzb.common.core.domain.AjaxResult;
import com.pzb.common.enums.BusinessType;
import com.pzb.market.domain.MkPanicbuyingGoods;
import com.pzb.market.service.IMkPanicbuyingGoodsService;
import com.pzb.common.core.page.TableDataInfo;

/**
 * 限时活动商品Controller
 * 
 * @author Mr_Wu
 * @date 2021-12-22
 */
@RestController
@RequestMapping("/market/panicGoods")
public class MkPanicbuyingGoodsController extends BaseController
{
    @Autowired
    private IMkPanicbuyingGoodsService mkPanicbuyingGoodsService;

    /**
     * 查询限时活动商品列表
     */
    @GetMapping("/list")
    public TableDataInfo list(MkPanicbuyingGoods mkPanicbuyingGoods)
    {
        startPage();
        List<MkPanicbuyingGoods> list = mkPanicbuyingGoodsService.selectMkPanicbuyingGoodsList(mkPanicbuyingGoods);
        return getDataTable(list);
    }

    /**
     * 获取限时活动商品详细信息
     */

    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(mkPanicbuyingGoodsService.selectMkPanicbuyingGoodsById(id));
    }

    /**
     * 新增限时活动商品
     */
    @Log(title = "限时活动商品", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody List<MkPanicbuyingGoods> panicbuyGoodsList)
    {
        return toAjax(mkPanicbuyingGoodsService.insertMkPanicbuyingGoods(panicbuyGoodsList));
    }

    /**
     * 修改限时活动商品
     */
    @Log(title = "限时活动商品", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MkPanicbuyingGoods mkPanicbuyingGoods)
    {
        return toAjax(mkPanicbuyingGoodsService.updateMkPanicbuyingGoods(mkPanicbuyingGoods));
    }


    /**
     * 删除限时活动商品
     */
    @Log(title = "限时活动商品", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mkPanicbuyingGoodsService.deleteMkPanicbuyingGoodsByIds(ids));
    }

    /**
     * 上移商品
     */
    @Log(title = "限时活动商品", businessType = BusinessType.UPDATE)
    @PostMapping("/moveUpGoods")
    public AjaxResult moveUpGoods(@RequestBody MkPanicbuyingGoods mkPanicbuyingGoods)
    {
        return toAjax(mkPanicbuyingGoodsService.moveUpGoods(mkPanicbuyingGoods ));
    }
    /**
     * 下移商品
     */
    @Log(title = "限时活动商品", businessType = BusinessType.UPDATE)
    @PostMapping("/moveDownGoods")
    public AjaxResult moveDownGoods(@RequestBody MkPanicbuyingGoods mkPanicbuyingGoods)
    {
        return toAjax(mkPanicbuyingGoodsService.moveDownGoods(mkPanicbuyingGoods));
    }

    /**
     * 状态修改
     */
    @Log(title = "限时活动商品", businessType = BusinessType.UPDATE)
    @PostMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody MkPanicbuyingGoods mkPanicbuyingGoods)
    {
        return toAjax(mkPanicbuyingGoodsService.updateMkPanicbuyingGoods(mkPanicbuyingGoods));
    }
}
